import { BUNDLE_TYPE_ENUM } from "../base/EnumIndex";
import { UIManager } from "../manager/UIManager";
import GlobalData from "./GlobalData";

const { ccclass, property } = cc._decorator;

@ccclass
export default class MenuUI extends cc.Component {
    public static instance: MenuUI = null;

    protected async onLoad() {
        MenuUI.instance = this;
    }

    private onBtnsClicked(event: cc.Event, data: cc.Event.EventCustom) {
        const name = event.target.name;
        switch (name) {
            case "btnStart":
                {
                    UIManager.ins.closeAll();
                    GlobalData.levelId = 1;
                    UIManager.ins.showUI("GameUI", BUNDLE_TYPE_ENUM.GAME_PLAY);
                }
                break;
            case "btnSetting":
                {
                    UIManager.ins.showPop("SettingUI", BUNDLE_TYPE_ENUM.GAME_PLAY);
                }
                break;
            case "btnFanKui":
                {
                    UIManager.ins.showPop("FanKuiUI", BUNDLE_TYPE_ENUM.GAME_PLAY);
                }
                break;
            case "btnRank":
                {
                    UIManager.ins.showPop("RankUI", BUNDLE_TYPE_ENUM.GAME_PLAY);
                }
                break;
            case "btnCollect":
                {
                    UIManager.ins.showPop("CollectUI", BUNDLE_TYPE_ENUM.GAME_PLAY);
                }
                break;
        }
        // console.log("onReviveClicked()===>按钮:", name);
    }
}